/*
 * @Author: 260156 260156@gree.com.cn
 * @Date: 2022-07-25 18:40:53
 * @LastEditors: 260156 260156@gree.com.cn
 * @LastEditTime: 2022-10-26 16:56:19
 * @FilePath: \gree-zst-web\src\router\index.ts
 * @Descriptiots
 *
 * Copyright (c) 2022 by 260156 260156@gree.com.cn, All Rights Reserved.
 */
import { createRouter, createWebHistory } from "vue-router";
import { setupRouterHooks } from "./routerHooks";
import { App } from "vue";

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "login",
    component: () => import("views/login/login.vue"),
  },
  {
    path: "/layout",
    name: "layout",
    component: () => import("@/layout/index.vue"),
    redirect: "/home",
    children: [],
  },
  {
    path: "/loginCallback",
    name: "loginCallback",
    component: () => import("views/login/login-callback.vue"),
  },
];

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_PUBLIC_PATH),
  routes,
});

export { router };

export function setupRouter(app: App<Element>): void {
  // 安装路由全局拦截钩子
  setupRouterHooks(router);
  app.use(router);
}
